﻿namespace Yipusoft.BaseDoc
{
    using System;
    using System.ComponentModel;
    using System.Data.Linq;
    using System.Data.Linq.Mapping;
    using System.Runtime.CompilerServices;

    [Table(Name="dbo.BaseDocs")]
    public class BaseDocs : INotifyPropertyChanging, INotifyPropertyChanged
    {
        private EntitySet<Yipusoft.BaseDoc.BaseDocFiles> _BaseDocFiles;
        private string _Caption;
        private string _Contents;
        private DateTime? _CreateDate;
        private Guid _ID;
        private string _Remark;
        private string _SetDepartment;
        private string _SetUserID;
        private int? _TID;
        private static PropertyChangingEventArgs emptyChangingEventArgs = new PropertyChangingEventArgs(string.Empty);

        public event PropertyChangedEventHandler PropertyChanged;

        public event PropertyChangingEventHandler PropertyChanging;

        public BaseDocs()
        {
            this._BaseDocFiles = new EntitySet<Yipusoft.BaseDoc.BaseDocFiles>(new Action<Yipusoft.BaseDoc.BaseDocFiles>(this.attach_BaseDocFiles), new Action<Yipusoft.BaseDoc.BaseDocFiles>(this.detach_BaseDocFiles));
        }

        private void attach_BaseDocFiles(Yipusoft.BaseDoc.BaseDocFiles entity)
        {
            this.SendPropertyChanging();
            entity.BaseDocs = this;
        }

        private void detach_BaseDocFiles(Yipusoft.BaseDoc.BaseDocFiles entity)
        {
            this.SendPropertyChanging();
            entity.BaseDocs = null;
        }

        protected virtual void SendPropertyChanged(string propertyName)
        {
            if (this.PropertyChanged != null)
            {
                this.PropertyChanged(this, new PropertyChangedEventArgs(propertyName));
            }
        }

        protected virtual void SendPropertyChanging()
        {
            if (this.PropertyChanging != null)
            {
                this.PropertyChanging(this, emptyChangingEventArgs);
            }
        }

        [Association(Name="BaseDocs_BaseDocFiles", Storage="_BaseDocFiles", ThisKey="ID", OtherKey="DID")]
        public EntitySet<Yipusoft.BaseDoc.BaseDocFiles> BaseDocFiles
        {
            get
            {
                return this._BaseDocFiles;
            }
            set
            {
                this._BaseDocFiles.Assign(value);
            }
        }

        [Column(Storage="_Caption", DbType="NVarChar(500)")]
        public string Caption
        {
            get
            {
                return this._Caption;
            }
            set
            {
                if (this._Caption != value)
                {
                    this.SendPropertyChanging();
                    this._Caption = value;
                    this.SendPropertyChanged("Caption");
                }
            }
        }

        [Column(Storage="_Contents", DbType="NVarChar(1000)")]
        public string Contents
        {
            get
            {
                return this._Contents;
            }
            set
            {
                if (this._Contents != value)
                {
                    this.SendPropertyChanging();
                    this._Contents = value;
                    this.SendPropertyChanged("Contents");
                }
            }
        }

        [Column(Storage="_CreateDate", DbType="DateTime")]
        public DateTime? CreateDate
        {
            get
            {
                return this._CreateDate;
            }
            set
            {
                if (this._CreateDate != value)
                {
                    this.SendPropertyChanging();
                    this._CreateDate = value;
                    this.SendPropertyChanged("CreateDate");
                }
            }
        }

        [Column(Storage="_ID", DbType="UniqueIdentifier NOT NULL", IsPrimaryKey=true)]
        public Guid ID
        {
            get
            {
                return this._ID;
            }
            set
            {
                if (this._ID != value)
                {
                    this.SendPropertyChanging();
                    this._ID = value;
                    this.SendPropertyChanged("ID");
                }
            }
        }

        [Column(Storage="_Remark", DbType="NVarChar(500)")]
        public string Remark
        {
            get
            {
                return this._Remark;
            }
            set
            {
                if (this._Remark != value)
                {
                    this.SendPropertyChanging();
                    this._Remark = value;
                    this.SendPropertyChanged("Remark");
                }
            }
        }

        [Column(Storage="_SetDepartment", DbType="VarChar(10)")]
        public string SetDepartment
        {
            get
            {
                return this._SetDepartment;
            }
            set
            {
                if (this._SetDepartment != value)
                {
                    this.SendPropertyChanging();
                    this._SetDepartment = value;
                    this.SendPropertyChanged("SetDepartment");
                }
            }
        }

        [Column(Storage="_SetUserID", DbType="VarChar(50)")]
        public string SetUserID
        {
            get
            {
                return this._SetUserID;
            }
            set
            {
                if (this._SetUserID != value)
                {
                    this.SendPropertyChanging();
                    this._SetUserID = value;
                    this.SendPropertyChanged("SetUserID");
                }
            }
        }

        [Column(Storage="_TID", DbType="Int")]
        public int? TID
        {
            get
            {
                return this._TID;
            }
            set
            {
                if (this._TID != value)
                {
                    this.SendPropertyChanging();
                    this._TID = value;
                    this.SendPropertyChanged("TID");
                }
            }
        }
    }
}

